<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>000</title>
		<style type="text/css">
			#text_body{
				border: 1px solid gray;
				padding: 20px;
			}
		</style>
	</head>
	<body>
<div class="center">
	昵称：<input type="text" id="myname" value="" />
	<p id="text_body"></p>
	<textarea style="width: 100%; height: 100px;" name="body" id="text_up" rows="" cols=""></textarea>
	<input type="button" id="btn_up" value="发送" />
</div>
	</body>
<script type="text/javascript" src="jq.min.js"></script>
<script type="text/javascript">
$(function(){
	var arr=['赵','钱','孙','李','周','吴','郑','王','张','刘','程','杨'];
	var len=arr.length;
	var num=Math.round(Math.random()*(len-1));
//	alert(num);
	$("#myname").val(arr[num]);
});
setInterval(function(){
//	console.log("a");
	var ajax = new XMLHttpRequest();
	ajax.open('get','ajax.php');
	ajax.send();
	ajax.onreadystatechange = function () {
		if (ajax.readyState==4 &&ajax.status==200) {
			var tall_txt=ajax.responseText;
			$("#text_body").html(tall_txt);
		}
	}
},100);
$("#btn_up").click(function(){
	var text_up=$("#text_up").val();
	var name_x=$("#myname").val();
//	console.log(text_up);
	var ajax = new XMLHttpRequest();
	ajax.open('get','text_up.php?text_up='+name_x+' : '+text_up);
	ajax.send();
	ajax.onreadystatechange = function () {
		if (ajax.readyState==4 &&ajax.status==200) {
			var tall_txt=ajax.responseText;
//			console.log(tall_txt);
		}
	}
	$("#text_up").val(null);
});
$("#text_body").click(function(){
	var ajax = new XMLHttpRequest();
	ajax.open('get','del_txt.php');
	ajax.send();
	ajax.onreadystatechange = function () {
		if (ajax.readyState==4 &&ajax.status==200) {
			var del_txt=ajax.responseText;
			$("#text_body").html(del_txt);
		}
	}
});
	
	
</script>
</html>
